import 'dart:typed_data';

import 'package:frontend/models/utils.dart';
import 'package:json_annotation/json_annotation.dart';

import 'itemInfo.dart';

part 'store.g.dart';

@JsonSerializable(explicitToJson: true)
class Store {
  String store_name;
  int store_id;
  int? favor;
  List<StoreItemInfo> items;

  Store(this.store_name, this.store_id, this.favor, this.items);

  factory Store.fromJson(Map<String, dynamic> json) => _$StoreFromJson(json);

  Map<String, dynamic> toJson() => _$StoreToJson(this);
}

@JsonSerializable(explicitToJson: true)
class StoreItemInfo {
  @JsonKey(toJson: bytes2base64, fromJson: base2bytes)
  Uint8List img;
  String name;
  int price;
  int id;
  String? buyer;
  int buyer_id;

  StoreItemInfo(
      this.img, this.name, this.price, this.id, this.buyer, this.buyer_id);

  factory StoreItemInfo.fromJson(Map<String, dynamic> json) =>
      _$StoreItemInfoFromJson(json);

  Map<String, dynamic> toJson() => _$StoreItemInfoToJson(this);
}
